package com.geh.learn.util;

import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 数据是有顺序的，可以有顺序的输出
 *
 * Created by gehui on 2017/2/23.
 */
public class LinkedHashMapLearn {
    public static void main(String[] args) {
        // 创建一个线程安全的Map
        Map<String, String> mapSafe = Collections.synchronizedMap(new LinkedHashMap<String, String>(){{put("key1", "value1");}});
        // 创建一个普通的LinkedMap
        Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(){
            {
                for (int i = 0; i<=10; i++) {
                    put(i, i);
                }
            }
        };

        for (Map.Entry<Integer, Integer> entry : map1.entrySet()) {
            System.out.println(entry.getValue());
        }
    }
}
